import {
    url
} from '../../modelApi/url_config.js'
const App = getApp()
let statusBarHeight = getApp().globalData.navHeight;
Page({
    data: {
        isSearch: false,
        statusBarHeight: statusBarHeight,
        fansListData: [], //粉丝列表数据
        pageobj: {
            pageNo: 1,
            pageSize: 10,
            type: '0',
            id: wx.getStorageSync('userId'),
            fansName: ''
        },
        textTalk: '',
        hasNextPage: false
    },
    onLoad() {
        this.getFansListFun()
    },
    cancelFunc() {
        this.data.pageobj.fansName = '';
        this.data.pageobj.pageNo = 1;
        this.setData({
            isSearch: false,
            pageobj: this.data.pageobj,
            textTalk: ''
        })
        this.getFansListFun()
    },
    bindconfirm(e) {
        if (e.detail.value.trim() === '') {
            wx.showToast({
                title: '搜索内容不能为空！',
                icon: 'none',
                duration: 2000
            })
            return
        }
        this.data.pageobj.fansName = e.detail.value;
        this.setData({
            pageobj: this.data.pageobj,
            isSearch: true
        })
        this.getFansListFun()
    },
    getFansListFun() {
        App.ajax(url.fansListUrl, this.data.pageobj, 'get').then(res => {
            this.setData({
                fansListData: res.rows,
                hasNextPage: res.hasNextPage
            })
        }).catch(err => {
            console.log(err)
        })
    },
    bindscrolltolower() {
        if (this.data.hasNextPage) {
            this.data.pageobj.pageNo++;
            this.setData({
                pageobj: this.data.pageobj
            })
            this.onLoadList();
        }
    }
})